package com.junlaninfo;

/**
 * Created by 辉 on 2020/12/28.
 * 冒泡排序
 */
public class test2 {
    public static void main(String[] args) {
        int[]  arr={13,46,22,65,3};
//        外圈for控制选循环的次数 4次
        for (int i=0;i<arr.length-1;i++){
            for(int  j=0;j<arr.length-1-i;j++){
                if (arr[j] > arr[j+1]) {
                    int temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }

            }
        }
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        for (int i = 0; i <= arr.length-1; i++) {
            if (i == arr.length - 1) {
                buffer.append(arr[arr.length-1] + "]");
            } else {
                buffer.append(arr[i]+",")
                ;
            }
        }
        System.out.println(buffer);
    }
}
